#include "Change/change.h"

Change::Change(opType newOp, int newRev, int newUser, int newDoc, int newPos) :
		Message(newOp)
{
	revisionId = newRev;
	userId = newUser;
	docId = newDoc;
	position = newPos;
}

QByteArray Change::toBytes()
{
	QByteArray bytes;
	QDataStream sout(&bytes, QIODevice::WriteOnly);

	sout << revisionId << userId << docId << position;

	return bytes;
}

/**
  *	Get the change details from a QByteArray
  */
Change::Change(QByteArray bytes)
{
	QDataStream sin(bytes);

	//get the operation
	quint8 op;
	sin >> op;
	operation = op;

	sin >> revisionId >> userId >> docId >> position;
}
